<?php

	/**
	 * 列表展示页面Model
	 */
	class ListModel extends Model{
		public $table = 'category';
		/**
		 * 返回相应分类中的所有商品
		 * 包含子分类中的所有商品
		 */
		 public function getCateGoods($cid){
		 	//获得所有的分类
		 	if($cid!=0){
		 		$cates 		= K('category')->getAllChild($cid);
				$cates[] 	= $cid;
				$cates 		= implode(',',$cates);
				//查询所有包含这些分类的商品
				$count = K('Goods')->getCateGoodsCount($cid);
				$goods['count'] = $count;
				$page = new Page($count,50,10);
				$goods['data'] = K('Goods')->getCateGoods($cates,$page->limit());
				$goods['count'] = count(K('Goods')->getCateGoods($cates,1000000));	
		 	}else{
		 		$count = K('Goods')->count();
		 		$page = new Page($count,50,10);
				$goods['count'] = $count;
				$goods['data'] = K('Goods')->limit($page->limit())->all();
		 	}
		 	$goods['page2'] = $page->show(3);
			$goods['page'] = $page->show(1);
			return $goods;
			
		 }
		
		 
		 
		 
		 
		 
		
		
	}
